package com.ftg.learn.student.controller;

import com.ftg.learn.student.entity.Menu;
import com.ftg.learn.student.entity.Student;
import com.ftg.learn.student.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author kangjx
 * @createTime 2022/7/29
 */
@RestController
public class StudentController {

    @Autowired
    StudentService studentServicel;

    @GetMapping("/show")
    public List<Student> abc(){
        return studentServicel.show();
    }

    @GetMapping("/allsc")
    public List<Student> showAllWithSc(){
        return studentServicel.showAllWithSc();
    }


    @GetMapping("/findid")
    public List<Student> findid(String id){
        return studentServicel.findid(id);
    }

    @GetMapping("/findid1")
    public List<Student> findid1(String id){
        return studentServicel.findid1(id);
    }

    @GetMapping("/findid2")
    public List<Student> findid2(String id){
        return studentServicel.findid2(id);
    }


    /**
     * post一般用做添  修改 删除
     * @return
     */
    @PostMapping("/save")
    public Map<String,Object> save(String sno, String sname, Integer ssage, String ssex){
        return studentServicel.save(sno,sname,ssage,ssex);
    }


    /**
     * post一般用做添  修改 删除
     * @return
     */
    @PostMapping("/savepojo")
    public Map<String,Object> savePojo(@RequestBody Student stu){
        return studentServicel.savePojo(stu);
    }

    @GetMapping("/allmenu")
    public List<Menu> allMenu(){
        return studentServicel.allMenu();
    }
}
